#include "LED/led.h"
#include "UART/uart.h"
#include "PLL/pll.h"
#include "PRINT/my_printf.h"
#include "VIC/vic_reg.h"
#include "INIT/init.h"
#include "EXTI/exti.h"
#include "TIMER/timer.h"
#include "PUBLIC/test.h"
#include "PUBLIC/public.h"

extern int over_flag;

void delay(uint t){
    while(t--);
}

int main(){
    u32 fp, sp;

    led_init();
    exti_init();
    // timer0_init();
    // timer2_init();
    print_cpsr();
    // print_PERIPHBASE();
    print_val("SDMMCVLKENB", 0xC00C5000);
    print_val("SDMMCCLKGEN0L", 0xC00C5004);
    

    __asm__(
        "mov %0, fp\n"
        "mov %1, sp\n"
        :"=r"(fp), "=r"(sp)
    );
    printf("main fp:%x sp:%x\r\n", fp, sp);

    // find(&over_flag);

    while(1){
        if(over_flag){
            dump(get_uint(), 64);
            over_flag = 0;
        }

        led1_on();
        delay(2000000);
        led1_off();
        delay(2000000);
        // printf("TCON_TIMER0: %x\r\n", TCNTO0_TIMER0);
    }

    return 0;
}
